#ifndef OBJ_H_INCLUDED
#define OBJ_H_INCLUDED

#include "model.h"

namespace sheeplib {

	namespace model {
	
		class OBJ : public Model {
			private:
				map<string, ModelMaterial> m_Materials;
			
				bool strStartsWith(const string& s, const string& stringToFind) const;
				void strStrip(string& s) const;
				vector<string> strSplit(const string& strIn, const string& delim) const;
				string strGetFilePath(const string& filename);
				
				slVec3 ReadVectorLine3(const string& line);
				slVec2 ReadVectorLine2(const string& line);
				
				bool ReadVertexLine(const string& line);
				bool ReadTexCoordLine(const string& line);
				bool ReadVertexNormalLine(const string& line);
				bool ReadFaceLine(const string& line);
				void ProcessFace(vector<int>& indexes, 
								 vector<int>& texIndexes, 
								 vector<int>& normIndexes);
								
				bool LoadMaterialFile(const string& filepath, const string& filename);
				
				vector<slVec3> m_TempVertices;
				vector<slVec2> m_TempTexCoords;
				vector<slVec3> m_TempNormals;
				
				unsigned int m_TempCurrentGroup; //Each time we encounter usemtl
					//we change this
			protected:
				bool LoadModelFile(const string& filename);
				void BasicGLRender() const;
				void Update(float dT) {} 
			public:
				void slBasicRender() const;
				void slRenderSubset(unsigned int i) const;
		};
	}
}

#endif // OBJ_H_INCLUDED
